/**
 * 
 */
package com.laozhao.dreamframe.util;

import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Window;


/**
 * @author LaoZhao
 *
 */
public class ToolsUtil  {

	/**
	 * 
	 */
	public ToolsUtil() {
	}
	
	public static String getRoot(){
		return ClassLoader.getSystemResource("").getPath();
	}
	/**
	 * 画面位置
	 */
	public static int X_POINT = Toolkit.getDefaultToolkit().getScreenSize().width / 2;
	public static int Y_POINT =  Toolkit.getDefaultToolkit().getScreenSize().height / 2;
	
	public static void setToCenter(Frame frame){
		if (frame != null && frame.isVisible()) {
			frame.setLocation(X_POINT - frame.getWidth()/2
							, Y_POINT - frame.getHeight() /2);
		}
	}
	
	public static void setToCenter(Window frame,Dialog dialog){
		if (frame != null && frame.isVisible()
				&& dialog != null ) {
			dialog.setLocation(frame.getLocationOnScreen().x +(frame.getWidth() - dialog.getWidth())/2
							, frame.getLocationOnScreen().y + (frame.getHeight() - dialog.getHeight()) /2);
		}
	}
}
